package mes.kanban.util;

import java.util.Date;
import java.util.Random;

/**
 * 密码生成器
 * @author gxy
 *	2018年5月23日
 *	paltformManager
 *
 */
public class PasswordBuildUtil {
	
	
	private final static String[] ZMS= {"q","w","e","r","t","y","u","i","o","p","a",
			"s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"};
	
	public synchronized static String returnNewPassword() {
		
		int zmsSize = ZMS.length;
		
		//取3个字母
		StringBuilder password = new StringBuilder();
		
		for (int i = 0; i < 3; i++) {
			int zmNum = new Random().nextInt(zmsSize-1);
			password.append(ZMS[zmNum]);
		}
		
		
		//取5个数字
		for (int i = 0; i < 5; i++) {
			password.append(new Random().nextInt(10));
		}
		
		//取3个字符或4个字符
		String date = String.valueOf(new Date().getTime());
		int num = Integer.valueOf(date.substring(date.length()-5, date.length()));
		if(num%2==0) {
			//取3个
			for (int i = 0; i < 3; i++) {
				int zmNum = new Random().nextInt(zmsSize-1);
				password.append(ZMS[zmNum]);
			}
		}else {
			for (int i = 0; i < 4; i++) {
				int zmNum = new Random().nextInt(zmsSize-1);
				password.append(ZMS[zmNum]);
			}
		}
		
		
		return password.toString();
		
	}
	

}
